package com.lqfan.autoAnswerQ.dao.subject;

import com.lqfan.autoAnswerQ.model.quesBank.QuesBankModel;
import com.lqfan.autoAnswerQ.model.subject.HandleImportModel;
import com.lqfan.autoAnswerQ.model.subject.Subject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lqfan
 * @since 2020-04-04
 */
@Mapper
public interface SubjectMapper extends BaseMapper<Subject> {

    @Insert("insert into subject (id,typeId,content,questionId) values(#{id}, #{typeId}, #{content}, #{questionId})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    int insertSub(Subject subject);

    @Select("select t_question *, t_subject *, t_")
    QuesBankModel getQuesBankModel();

    @Update("update subject s,question q set s.isCollect= #{isCollect} where q.id=s.questionId and  s.id= #{id} and q.userId =#{userId}")
    boolean collectSub(Integer isCollect,String id,String userId);

    @Select("select * from subject where id=#{subjectId}")
    Subject getSubject(String subjectId);

    @Select("select * from subject where isCollect=1 and userId =#{userId}")
    List<Subject> getCollectSubject(String userId);
}
